
import android.os.Parcel
import android.os.Parcelable

data class Topic(
        var topicId: Long = 0,
        var userId: Int = 0,
        var userName: String = "",
        var userImg: String = "",
        var title: String = "",
        var content: String = "",
        var imgsUrl: String = "",
        var replayCount: Int = 0,
        var praise: Int = 0,
        var status: Int = 0,
        var audit: String = "",
        var createAt: Long = 0,
        var replyAt: Long = 0
) : Parcelable {
    constructor(parcel: Parcel) : this(
            parcel.readLong(),
            parcel.readInt(),
            parcel.readString(),
            parcel.readString(),
            parcel.readString(),
            parcel.readString(),
            parcel.readString(),
            parcel.readInt(),
            parcel.readInt(),
            parcel.readInt(),
            parcel.readString(),
            parcel.readLong(),
            parcel.readLong())

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeLong(topicId)
        parcel.writeInt(userId)
        parcel.writeString(userName)
        parcel.writeString(userImg)
        parcel.writeString(title)
        parcel.writeString(content)
        parcel.writeString(imgsUrl)
        parcel.writeInt(replayCount)
        parcel.writeInt(praise)
        parcel.writeInt(status)
        parcel.writeString(audit)
        parcel.writeLong(createAt)
        parcel.writeLong(replyAt)
    }

    override fun describeContents(): Int {
        return 0
    }

    override fun toString(): String {
        return "Content(topicId=$topicId, userId=$userId, userName='$userName', userImg='$userImg', title='$title', content='$content', imgsUrl='$imgsUrl', replayCount=$replayCount, praise=$praise, status=$status, audit='$audit', createAt=$createAt, replyAt=$replyAt)"
    }

    companion object CREATOR : Parcelable.Creator<Topic> {
        override fun createFromParcel(parcel: Parcel): Topic {
            return Topic(parcel)
        }

        override fun newArray(size: Int): Array<Topic?> {
            return arrayOfNulls(size)
        }
    }


}